﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;

namespace IHISCETeim.BLL
{
    public class SKuaiDi100Controller : BaseController
    {
        public static DataTable GetAll()
        {
            DataTable list = DC.Get<DataTable>(ALLKuaiDICompanyKey);
            if (list == null)
            {
                list = SKuaiDi100DAL.GetAll();
                DC.Add(ALLKuaiDICompanyKey, list);
            }

            return list;
        }

        public static string GetKuaiDi100(string com,string nu)
        { 
            //1.先根据提供的COM 获取公司信息，
            string _com=com.Length>2?com.Substring(0,2):com;
            DataTable list = GetAll();
            DataTable rsv=list.Select(string.Format("kuaidicom like '{0}%'", _com)).CopyToDataTable() ;
            if (rsv.Rows.Count > 0)
            {
                return string.Format("<a href=\"http://www.kuaidi100.com/chaxun?com={0}&nu={1}\" target='_blank' >{1}</a>", rsv.Rows[0]["kuaidinu"], nu);
            }

            return nu;
        }

    }
}
